package wnhz.com.business.uitls.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import wnhz.com.business.R;

/**
 * Created by wanghongchuang
 * on 2016/8/25.
 * email:844285775@qq.com
 */
public class UpgradeDialog extends Dialog implements View.OnClickListener {

    private OnButtonClick mButtonClick;

    private int negTextColorid;
    private int posTextColorid;

    TextView tv_upgrade;
    boolean mIsClickDismiss = true;

    public interface OnButtonClick {
        void onNegBtnClick();
    }

    public UpgradeDialog(Context context) {
        super(context, R.style.updialog);
        init(context, null);
    }

    public UpgradeDialog(Context context, OnButtonClick buttonClick) {
        super(context, R.style.updialog);
        init(context, buttonClick);
    }

    public UpgradeDialog(Context context, String confirm, OnButtonClick buttonClick) {
        super(context, R.style.updialog);
        init(context, buttonClick);
    }

    public UpgradeDialog(Context context, String cancel, String confirm, OnButtonClick buttonClick) {
        super(context, R.style.updialog);
        init(context, buttonClick);
    }

    public UpgradeDialog(Context context, OnButtonClick buttonClick, String num) {
        super(context, R.style.updialog);
        init(context,buttonClick);
    }

    public void init(Context context, OnButtonClick buttonClick) {
        this.mButtonClick = buttonClick;
        View v = LayoutInflater.from(context).inflate(R.layout.dialog_upgrade, null);

        tv_upgrade = (TextView) v.findViewById(R.id.tv_upgrade);

        tv_upgrade.setOnClickListener(this);
        setContentView(v);
    }

    public void setPosBtnTextColor(int id) {
        posTextColorid = id;
    }

    public void setNegBtnTextColor(int id) {
        negTextColorid = id;
    }

    public void setIsDismissClick(boolean isClickDismiss) {
        mIsClickDismiss = isClickDismiss;
    }

    @Override
    public void onClick(View v) {
        if (v == tv_upgrade) {
            if (mButtonClick != null) {
                mButtonClick.onNegBtnClick();
            }
        }
        if (mIsClickDismiss) {
            dismiss();
        }
    }
}
